import Vue from 'vue'
import Vuex from 'vuex'
import {BASE_URL, RETUNIT_LIST, PRODUCT_TYPE_LIST, ORDER_STATUS_LIST, ORDER_TAG_TYPE_LIST, GENDER_LIST, PAYMENT_TYPE_LIST } from './constant'
import user from './modules/user'
import app from './modules/app'
import order from './modules/order'
Vue.use(Vuex)

const store = new Vuex.Store({
  modules: {
    user,
    app,
    order
  },
  state: {
    BASE_URL,
    RETUNIT_LIST,
    PRODUCT_TYPE_LIST,
    ORDER_STATUS_LIST,
    ORDER_TAG_TYPE_LIST,
    GENDER_LIST,
    PAYMENT_TYPE_LIST
  },
  mutations: {

  },
  actions: {},
  getters: {
    BASE_URL: state => state.BASE_URL,
    GENDER_LIST: state => state.GENDER_LIST,
    RETUNIT_LIST: state => state.RETUNIT_LIST,
    PAYMENT_TYPE_LIST: state => state.PAYMENT_TYPE_LIST,
    token: state => state.user.token,
    alipay_account: state => state.app.alipay_account,
    wechat_account: state => state.app.wechat_account,
    hasLogin: state => {
      return state.user.hasLogin || state.user.token !== ''
    },
    userInfo: state => state.user.userInfo,
    userBasicInfo: state => state.user.userBasicInfo,
    userAddressBook: state => state.user.userAddressBook,
    selectedContact: state => state.user.selectedContact,
    emergencyContact: state => state.user.emergencyContact,
    ifHideAppByManual: state => state.user.ifHideAppByManual,
    ifPassedLiveness: state => state.user.ifPassedLiveness,
    webViewUrl: state => state.app.webViewUrl,
    orderFlowStatus: state => state.order.orderFlowStatus,
    orderParams: state => state.order.orderParams,
    productInfo: state => state.order.productInfo,
    orderAddress: state => state.order.orderAddress
  }
})

export default store